<?php
		session_start();
		$acceso=$_SESSION['pediatria_acceso'];
		if($acceso==1||$acceso==2){//solo tendra acceso el administrador

                $idSecretaria=$_SESSION['pediatria_idusuario'];

	?>

<?php
    include 'class/ORMDoctor.php';
    include_once 'class/ORMCita.php';
?>
<html>
    <head>
        <title>Pediatr&iacute;a</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <link href="css/style.css" rel="stylesheet" type="text/css">
        <link type="text/css" href="css/menu.css" rel="stylesheet" />
        <script type="text/javascript" src="js/jquery.js"></script>
        <script type="text/javascript" src="js/menu.js"></script>
        
        <script type="text/javascript" src="js/buscar.js"></script>
        <link type="text/css" href="css/start/jquery-ui-1.8.16.custom.css" rel="stylesheet" />
        <script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
        <script type="text/javascript" src="js/jquery-ui-1.8.16.custom.min.js"></script>
        <script type="text/javascript">
            $(function() {
                $('input[type="button"]').button();
                $("#txtFecha").datepicker();
                $("#txtFecha").datepicker("option", "dateFormat","yy-mm-dd");
                $("#txtFechaNuevaCita").datepicker();
                $("#txtFechaNuevaCita").datepicker("option", "dateFormat","yy-mm-dd");

            });
        </script>
    </head>
    <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" >
        <table width="100%" height="100%" border="0" style="vertical-align: top" align="center" cellpadding="0" cellspacing="0">
            <tr><!- encabezado ->
                <?php
                include("content/encabezado.php");
                ?>
            </tr><!-  FIN encabezado ->
            <tr><!-  INICIO MENU ->
                <td height="75" background="images/top02bg_1.gif" style="margin-bottom: 0;background-repeat: repeat-x; vertical-align: top;">
                    <br/>
                    <?php
                    include("content/menu.php");
                    ?>
                </td>
            </tr><!-  FIN MENU ->
            <tr>
                <td align="center" valign="top" bgcolor="F8FFE9">
                    <table style="min-width: 600px" height="100%" border="0" cellpadding="0" cellspacing="0" class="text" align="center">
                        <tr>
                            <td width="539" align="left" valign="top">
                                <table width="650" border="0" height="100%" cellpadding="0" cellspacing="0" class="text">

                                    <tr>
                                        <td align="center" valign="top" bgcolor="F8FFE9" height="100%">
                                            <!- INicio de contenido->
                                            <div style="padding: 10px" >
                                                <h1 align="center">Nueva Cita</h1><br/>
                                                <h3 align="left">Buscar paciente</h3>
                                                <hr>
                                                <table border="0" width="100%">
                                                    <tr>
                                                        <td>
                                                            <table border="0" align="left">
                                                                <tr><td><label>Identificaci&oacute;n:</label></td><td><input type="text" id="identidad1" ></td></tr>
                                                                <tr><td><label>Nombre:</label></td><td><input type="text" id="nombre1"></td></tr>
                                                                <tr><td><label>No. Expediente:</label></td><td><input type="text" id="expediente1"></td></tr>
                                                            </table>
                                                        </td>
                                                    </tr>
                                                    <tr><td align="left" colspan="2"><input type="button" value="Buscar"  class="boton" onclick="BuscarCita(identidad1.value, nombre1.value, expediente1.value)"></td>
                                                    </tr>

                                               
                                                 </table><br/>

                                                <h3 align="left">Datos del paciente</h3>
                                                <hr><br/><div id="2">
                                                <table border="0" width="100%">
                                                    <tr>
                                                        <td><label>No. expediente</label></td><td><input type="text" disabled readonly="true" id="expediente"/></td>
                                                    </tr>
                                                    <tr>
                                                        <td><label>Nombre completo</label></td><td><input type="text" disabled readonly="true" id="nombreCompleto"/></td>
                                                    </tr>
                                                    <tr>
                                                        <td><label>Identificaci&oacute;n:</label></td><td><input type="text" disabled readonly="true" id="identidad" name="identidad"/></td>
                                                    </tr>
                                                    
                                                </table></div>
                                                 
                                                &nbsp;<br/>
                                                <h3 align="left">Asignar Cita</h3>
                                                <hr><br/>
                                                 <table width="100%" border="0">
                                                       <?php
                                                            $OrmDoc = new ORMDoctor();
                                                         
                                                            $queryOrmDoc = $OrmDoc->obtenerNombreDoctor();
                                                            echo"<tr><td><label>Doctor:</label></td><td><select id='Doctor' onclick=''>
                                                                <option>---</option>";
                                                            while ($row = mysql_fetch_assoc($queryOrmDoc)) {
                                                                echo "<option>$row[nombre]</option>";
				}
                                                            echo"</select></td></tr>
                                                                <tr><td><label>Hora:</label></td><td><select id='Hora' >
                                                                <option>---</option>
                                                                <option>7:00 am</option>
                                                                <option>8:00 am</option>
                                                                <option>9:00 am</option>
                                                                <option>10:00 am</option>
                                                                <option>11:00 am</option>
                                                                <option>12:00 m</option>
                                                                <option>1:00 pm</option>
                                                                <option>2:00 pm</option>
                                                                <option>3:00 pm</option>
                                                                <option>4:00 pm</option>
                                                                <option>5:00 pm</option>
                                                                <option>6:00 pm</option>
                                                                <option>7:00 pm</option>
                                                                </select></td></tr>
                                                                ";
                                ;?>
                                                    <tr><td><label>Fecha:</label></td><td><input type="text" id="txtFechaNuevaCita"/></td></tr>
                                                    <tr><td><label>Observaciones:</label></td><td><textarea rows="3"  cols="40"></textarea></td></tr>

                                                    <tr><td align="left" colspan="2"><input type="button" value="Guardar" class="boton" onclick="GuardarCita(expediente.value,Doctor.value,txtFechaNuevaCita.value,Hora.value)"></td></tr>
                                                </table><br/><br/>


                                                <h3 align="left">Lista de citas</h3>
                                                <hr><br/>
                                                 <div id="3">
                                                <table border="0" width="100%" class="estilo_tabla">
                                                    
                                                    <tr class="tr_impar">
                                                        <td colspan="7">&nbsp;</td>
                                                    </tr>
                                                    <tr class="titulo_tabla">
                                                        <td>No. expediente</td><td>Fecha/Hora</td><td>Identificaci&oacute;n</td><td>Nombre completo</td><td colspan="3">Opciones</td>
                                                    </tr>
                    <?php
                                $ormCita = new ORMCita();
                                $consulta = $ormCita->Todos();
                                $i=0;
				while ($row = mysql_fetch_assoc($consulta)) {
				$i++;
				if(($i%2)==0){
					echo "<tr class='tr_par'>";
				}else{
					echo "<tr class='tr_impar'>";
				}
  				echo "<td><center>$row[Paciente_Persona_idPersona]</center></td>
					  <td><center>$row[fecha]/$row[hora]</center></td>
					  <td>$row[identidad]</td>
					  <td><center>$row[nombre]</center></td>
                                          <td><center>$doctor</center></td>
					  <td><a href='EditarCita.php?cita=$row[idCita]&expediente=$row[Paciente_Persona_idPersona]&nombre=$row[nombre]&identificacion=$row[identidad]'>Editar </a>&nbsp;&nbsp;<a href='class/eliminarCita.php?idCita=$row[idCita]'>Eliminar</a></td>";
                   }?>
                                                </table></div>
                                                <br/><br/>

                                            </div>

                                        </td><!- FIN de contenido->
                                    </tr>
                                </table></td>


                        </tr>
                    </table></td></tr>
            <tr>
               
                <?php
                    include("content/pie_page.php");
                ?>

            </tr>

        </table>
        <div id="copyright" style="display: none">Copyright &copy; 2011 <a href="http://apycom.com/">Apycom jQuery Menus</a></div>

    </body>
</html>

<?php
	}else{
		header("Location: index.php");
	}
	?>